package training.hari;

import java.util.Scanner;

public class JavaBasics {

	public void basicVariables() {
		boolean result = false;
		byte byte1;
		short shortNumber;
		int intNumber;
		long longVariable;
		float floatVariable;
		double doubleVariable;

		char charVariable = 'H';
		String name = "Java training";

		Scanner scanner = new Scanner(System.in);
		System.out.println("Next boolean");
		result = scanner.nextBoolean();

		System.out.println("Next byte");
		byte1 = scanner.nextByte();

		System.out.println("Next short");
		shortNumber = scanner.nextShort();
		System.out.println("Next int");
		intNumber = scanner.nextInt();
		System.out.println("Next long");
		longVariable = scanner.nextLong();
		System.out.println("Next float");
		floatVariable = scanner.nextFloat();
		System.out.println("Next double");
		doubleVariable = scanner.nextDouble();

		System.out.println("result is :" + result);
		System.out.println("result byte is " + byte1);
		System.out.println("result byte is " + byte1);
	}
	
	
	public void demoDataTypeRange(){
		
		 byte number = (byte)130;
		 System.out.println("number beyond range example :" + number);
	}
	
	public void demoIfAndFor(){
		int i = 10;

		if (i == 5) {
			System.out.println("i value is 5");
		} else if (i == 9) {
			System.out.println("i value is 9");

		} else {
			System.out.println("i value is not 5 or 9");
		}

		for (i = 0; i < 10; i++) {
			System.out.println("next number is :" + i);
		}
	}
	
	public void demoWhile(int i){
		System.out.println("i value before while loop start :" + i);
		while(i <10){
			System.out.println(" i is :" + i);
			i++; //i=i+1;
		}
		System.out.println("After while loop");
	}

	
	public void demoDoWhile(int i){
		System.out.println("i value before demoDoWhile loop start :" + i);
		do{
			
			System.out.println("i value in doWhile is :" + i);
			i++;
		}while(i<10);
		System.out.println("After demoDoWhile loop");
	}
	
	
	public void demoSwitch(int i){
		
		switch(i){
		case 1:
			System.out.println("The value of i is :" + i);
			//break;   //if you dont use break, it will continue executing next cases code as well.
		case 2:
			System.out.println("The value of i is :" + i);
			break;
		case 3:
			System.out.println("The value of i is :" + i);
			break;
		default:
			System.out.println("default: i value is" + i);
		}
	}
	
	
	public static void main(String[] args) {

		JavaBasics basics = new JavaBasics();
		// basics.basicVariables();
		basics.demoDataTypeRange();
		//basics.ifFor();

		//basics.demoWhile(0);
		//basics.demoWhile(20);
		
	//	basics.demoDoWhile(0);
	//	basics.demoDoWhile(20);
		
		basics.demoSwitch(1);
		basics.demoSwitch(2);
		basics.demoSwitch(10);


	}

}
